package com.shuzijun.leetcode.editor.cn;
public class FindMinimumInRotatedSortedArray{
    public static void main(String[] args) {
         Solution solution = new FindMinimumInRotatedSortedArray().new Solution();
        
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int findMin(int[] nums) {
        int low = 0;
        int high = nums.length-1;
        while (low <= high){
            int mid = (low+high)/2;
            if (low == high){
                return nums[mid];
            }

            if ((mid != 0 && nums[mid] < nums[mid-1])
                    || (mid == 0 && nums[mid] < nums[high])){
                return nums[mid];
            } else if (nums[mid] > nums[high]) {
                low = mid+1;
            }else {
                high = mid-1;
            }
        }
        return -1;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}